For Task Tracker to function on a mass scale, it needs to have definable tasks that run on a per-server
basis.
This means the information for each server needs to be stored somewhere.
This section goes through each attempt of solving this issue.
DS: Iteration #1
The first iteration used a global database to store server data. I worked on this concept for some time
before realizing I obviously could not store a database of possibly private information that I could access.
DS: Iteration #2
The second and last iteration uses a mix of local data and a global list to define the server data (tasks).
As an example, to register the bot, you would first invite it via a special link. Once in the server, run
the
register command (as will be documented) to register your server.
This command will write the default settings to a private (excluding server admins/owner) channel and add
the ID to the global list, after that
completes, a help message to get started with the SetupWizard is displayed to the user.
- Global List |
JSON
The global list is a JSON file hosted on a private discord server.
This file contains no personal information, only a dictionary of channel IDs with a value of 0.
It is created like this so no duplicates can be made.
Each channel ID references a channel in which a local settings file exists.
When the code to execute tasks runs, it iterates through this dictionary and adds a new async function for
each channel.
The async function downloads the local settings and parses them; if any tasks are set to run at
DateTime.Now
they are executed accordingly.
- Local Settings |
JSON
The local settings file is also a JSON file, but it is hosted in the server (local to that server).
This file contains two primary indexes, "vars" and "tasks" and one property "timezone".
The Vars dictionary holds user-defined variables that can be used in the task message.
Tasks define what happens at any point in time. Only a basic notification system is implemented
as of now, but over time it could expand to support a broader range of things.
All of this data will be formatted by the SetupWizard where you can add/remove tasks and variables.
DS: Iteration #3
In the original server settings, tasks were defined as a
Dictionary<string,
Dictionary<string, dynamic>>
,
the first
string
being the DateTime.
This needs to be removed because all dictionary keys
must be unique, having only one task per
time, we are restricted from running multiple tasks at any given time.
The new solution is to add the time as a property inside the dictionary and give a unique hex-based id to
each task. |
Download updated JSON
data.
DS: Iteration #4
Having the tasks in a dictionary is reduntant outside of the Setup Wizard (where the ID is used for saving),
it is therefore removed and made into a list in the server-side data. |
Download updated JSON
data.